package com.example.demo.system.controller;

import com.example.demo.system.entity.Permission;
import com.example.demo.system.service.PermissionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.Valid;
/**
* @author 许久龙
* @since 2022-02-19
*/
@RestController
@RequestMapping("api")
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

    @GetMapping("/permission")
    @ApiOperation("Permission查询单个")
    public ResultVO getPermission(@RequestBody Permission permission){
     ResultVO resultVO = permissionService.getPermission(Permission permission);
     return  resultVO;
   }

    @GetMapping("/permission")
    @ApiOperation("Permission查询全部")
    public ResultVO getAllPermission(){
        ResultVO resultVO = permissionService.getAllPermission();
        return  resultVO;
    }

    @PostMapping("/permission")
    @ApiOperation("Permission新增")
    public ResultVO add(@Valid @RequestBody Permission permission) {
        ResultVO resultVO = permissionService.add(Permission permission);
        return  resultVO;
    }

    @PutMapping("/permission")
    @ApiOperation("Permission修改")
    public ResultVO update(@Valid @RequestBody Permission permission) {
        ResultVO resultVO = permissionService.update(Permission permission);
        returnresultVO;
    }


    @DeleteMapping(value = "/permission/{ids}")
    @ApiOperation("Permission删除(单个条目)")
    public ResultVO remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        ResultVO resultVO = permissionService.remove(String ids);
        return resultVO;
    }
}
